package GUI;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.io.IOException;
import java.util.Vector;

import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JSeparator;
import javax.swing.SwingConstants;

import DataObjects.Menu;
import Messages.MessageShowAllRecipesThatCanBuy;
import Messages.MessageShowAllRecipesThatCanBuyReply;


/**
 * this class create right panel with buttons for choose of the needs menus of the restaurant(using by waiter).This panel is based on the right side
 *  after pressing the   " תפריט" .
 *  @author Andrey
 */

public class PanelFunctionsMenu extends PanelFunctionsEmpty{
	private static final long serialVersionUID = 1L;
	private JButton button_business_menu;
	private JButton button_standart_menu;
	private MainMenu mainMenu;
	private Vector<Menu> allTheMenus;
	
	
	public PanelFunctionsMenu(MainMenu mm,Vector<Menu> theMenus )
	{
		super();	
		this.mainMenu=mm;
		this.allTheMenus=theMenus;
		//this.add(get_button_business_menu());
		initialize();
		
		
	}
	
	private void	initialize()
	{
		for(int i=0; i<allTheMenus.size();i++)
			
		{	
			if(allTheMenus.get(i).getType().equals("business"))
			this.add(getBusinessMenusButtons( allTheMenus.get(i)));  //one of business menu
			
			
		}
		
		this.add(getStandartMenuButton());  // standard menu	
		
	}
	
	/**
	 * Method that creating buttons for business menu on the right panel
	 * @param m
	 * @return
	 */
	private JButton getBusinessMenusButtons(Menu m)
	{
		final Menu menu=m;
		JButton menuButt=new JButton(menu.getName());
		menuButt.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 15));
		menuButt.setPreferredSize(new Dimension(220, 30));
		menuButt.addActionListener(new java.awt.event.ActionListener() 
		   {
			public void actionPerformed(java.awt.event.ActionEvent e) 
			{
				mainMenu.getContentPane().remove(((BorderLayout)mainMenu.getContentPane().getLayout()).getLayoutComponent(BorderLayout.CENTER));
				mainMenu.getContentPane().add(new PfGeneral_menu1(mainMenu,menu.getRecipes(),menu.getName()), BorderLayout.CENTER);	
				mainMenu.getContentPane().validate();	
				
				}
				
					
		});
		   
		return menuButt;
	}
	
	/**
	 * Method that creating button for standard  menu on the right panel
	 * @param m
	 * @return
	 */
	private JButton getStandartMenuButton()
	{
		
		JButton standardMenuButt=new JButton("תפריט רגיל");
		standardMenuButt.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 15));
		standardMenuButt.setPreferredSize(new Dimension(220, 30));
		standardMenuButt.addActionListener(new java.awt.event.ActionListener() 
		   {
			public void actionPerformed(java.awt.event.ActionEvent e) 
			{
				mainMenu.getContentPane().remove(((BorderLayout)mainMenu.getContentPane().getLayout()).getLayoutComponent(BorderLayout.CENTER));
				mainMenu.getContentPane().add(new PfStandardMenus(mainMenu, allTheMenus), BorderLayout.CENTER);	
				mainMenu.getContentPane().validate();	
				
				}
				
					
		});
		   
		return standardMenuButt;
	}
	
}
